GBML manual / Events

button

Runs for one of the ten buttons, on one of three phases: Pressed (the frame it went down), Held (every frame it stays down), Released (the frame it went up).

Syntax

button: Button Pressed/Held/Released <button> - fires while/when that button matches that phase

Description

One event kind, three phases, over the GBA's own ten buttons: Pressed (the one frame a button first goes down), Held (every frame it stays down), Released (the one frame it goes back up) - pick whichever button and phase an object actually needs, one event per combination.

Dispatch loops over the ten buttons, not over instances, so an object with no button events at all costs nothing here on an ordinary frame. The same three phases are also readable directly as btn_pressed/btn_held/btn_released from inside any other event (typically Step) - reach for a Button event when the object's whole reason for existing is that one press, and a plain if (btn_pressed(...)) inside Step when it is one check among several.

Example

// objects/obj_doc_walker/button_pressed_A.gbml
instance_create(x, y, obj_doc_bolt);

Fires once, the frame the A button first goes down - no btn_pressed(BTN_A) check needed, since the event itself only runs on that exact frame.

On the GBA

Dispatch loops over the 10 buttons, not over instances - an object with no button handlers costs nothing here, most frames.

See also: btn_pressedbtn_heldbtn_releasedEvents